package org.jeecg.modules.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.system.entity.ZkEquipmentOverhaul;
import org.jeecg.modules.system.entity.ZkEquipmentOverhaulDetail;
import org.jeecg.modules.system.mapper.ZkEquipmentOverhaulMapper;
import org.jeecg.modules.system.service.IZkEquipmentOverhaulService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: 设备检修表
 * @Author: jeecg-boot
 * @Date:   2024-04-28
 * @Version: V1.0
 */
@Service
public class ZkEquipmentOverhaulServiceImpl extends ServiceImpl<ZkEquipmentOverhaulMapper, ZkEquipmentOverhaul> implements IZkEquipmentOverhaulService {

    //设备检修根据当前登录人员和时间查询
    @Override
    public List<ZkEquipmentOverhaul> queryPageListVo(Integer pageNo, Integer pageSize) {
        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentOverhaul> page = new Page<ZkEquipmentOverhaul>(pageNo,pageSize);
        List<ZkEquipmentOverhaul> list=this.baseMapper.queryPageListVo(page,sysUser.getId());
        return list;
    }

    /**
     * 审批界面/检修（根据当前登录人和状态分页查询）
     * @return
     */
    @Override
    public IPage<ZkEquipmentOverhaulDetail> queryZkEquipmentOverhaulDetail(Integer pageNo, Integer pageSize) {
        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentOverhaulDetail> page = new Page<ZkEquipmentOverhaulDetail>(pageNo,pageSize);

        return this.baseMapper.queryZkEquipmentOverhaulDetail(page,sysUser.getId());
    }

    /**
     * 发起界面/检修（根据当前登录人和状态分页查询）
     * @return
     */
    @Override
    public IPage<ZkEquipmentOverhaulDetail> queryZkEquipmentOverhaulList(Integer pageNo, Integer pageSize) {
        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentOverhaulDetail> page = new Page<ZkEquipmentOverhaulDetail>(pageNo,pageSize);

        return this.baseMapper.queryZkEquipmentOverhaulList(page,sysUser.getId());
    }
    /**
     * 抄送任务(保养)（根据当前登录人和状态将维修，保养，检修放在同一个分页查询中）
     * @return
     */
    @Override
    public IPage<ZkEquipmentOverhaulDetail> queryZkEquipmentOverhaulCc(Integer pageNo, Integer pageSize) {
        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentOverhaulDetail> page = new Page<ZkEquipmentOverhaulDetail>(pageNo,pageSize);

        return this.baseMapper.queryZkEquipmentOverhaulCc(page,sysUser.getId());
    }

    /**
     * 查询全部数据，修改状态
     */
    @Override
    public List<ZkEquipmentOverhaul> queryZkEquipmentOverhaul() {
        return this.baseMapper.queryZkEquipmentOverhaul();
    }

    /**
     * 保养柱状图PC端首页(根据检修周期统计数量)
     */
    @Override
    public List<Map<Integer, Integer>> pcCount() {
        return this.baseMapper.pcCount();
    }

}
